package com.friddle.util;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by friddle on 12/25/14.
 */
public class Assert {
    public static void assertNotNullExit(Object object)
    {
        if(object==null)
        {
            System.out.print(object.getClass().toString()+"is null");
            System.exit(0);
        }
    }

	public static void assertNotClassTypeException(Class classtype,Object object)
	{
		if(!object.getClass().equals(classtype))
		{
			System.out.print(classtype.getSimpleName().toString()+"is null");
			throw new IllegalArgumentException("the "+classtype+" exception");
		}
	}

    public static void assertNotNullException(Object object)
    {
        if(object==null)
        {
            System.out.print(object.getClass().toString()+"is null");
            throw new NullPointerException(object.getClass().getName());
        }
    }

	public static void assertBooleanException(boolean istrue)
	{
		if(!istrue)
		{
			throw new NullPointerException("not equals");
		}
	}
    public static void checkUrl(String url)
    {
        try {
            URL newurl = new URL(url);
        } catch (MalformedURLException e) {
            throw  new IllegalArgumentException("the url not work:"+url);
        }

    }

}
